When the following conditions are met in PROC SURVEYMEANS:
the quantiles and standard errors are incorrect from the empty domain through the last row in the Domain Quantiles table. An output data set generated from the DomainQuantiles ODS table is similarly affected.
Quantiles are requested when any of the following options are specified in the PROC SURVEYMEANS statement:
You can detect an empty domain by specifying the NOBS option in the PROC SURVEYMEANS statement and checking the Domain Statistics table. A value of N=0 indicates an empty domain.
To circumvent the problem, create a new domain variable using a custom format that places the empty domain in the last sorted order. Click the Full Code tab for an example.
Product Family | Product | System | Product Release | SAS Release | ||
Reported | Fixed* | Reported | Fixed* | |||
SAS System | SAS/STAT | z/OS | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 |
Microsoft® Windows® for x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8 Enterprise 32-bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8 Enterprise x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8 Pro 32-bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8 Pro x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8.1 Enterprise 32-bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8.1 Enterprise x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8.1 Pro 32-bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 8.1 Pro x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows 10 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows Server 2008 | 13.1 | 9.4 TS1M1 | ||||
Microsoft Windows Server 2008 R2 | 13.1 | 9.4 TS1M1 | ||||
Microsoft Windows Server 2008 for x64 | 13.1 | 9.4 TS1M1 | ||||
Microsoft Windows Server 2012 Datacenter | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows Server 2012 R2 Datacenter | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows Server 2012 R2 Std | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Microsoft Windows Server 2012 Std | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Enterprise 32 bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Enterprise x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Home Premium 32 bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Home Premium x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Professional 32 bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Professional x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Ultimate 32 bit | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Windows 7 Ultimate x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
64-bit Enabled AIX | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
64-bit Enabled Solaris | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
HP-UX IPF | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Linux for x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 | ||
Solaris for x64 | 13.1 | 14.3 | 9.4 TS1M1 | 9.4 TS1M5 |
*The following DATA step generates a test data set A with four levels of Education and random values of Y.
One of the Education levels, 'College Grad', is empty because it is assigned a missing value of Y
for every one of its observations.;
data a;
length Education $ 15;
do Education='High School', 'Some College', 'College Grad', 'Advanced Degree';
do i=1 to 25;
y=rannor(12345);
if Education='College Grad' then y=.;
output;
end;
end;
run;
*The number of observations, mean and median of Y are requested for the overall data set and the domain levels;
title "N=0 for a domain level";
title2 "The quantile results are incorrect starting from the empty domain";
proc surveymeans data=a nobs mean median;
var y;
domain Education;
run;
title;
*Notice in the output that N=0 for College Grad, indicating an empty domain;
*The quantile results in the Domain Quantiles table are incorrect for the College Grad level and all subsequent Education levels.;
*The following PROC FORMAT step creates a custom format, REORDER, which places College Grad last if you sort on the formatted values;
proc format;
value $ reorder
'High School'='(1) High School'
'Some College'='(2) Some College'
'Advanced Degree'='(3) Advanced Degree'
'College Grad'='(4) College Grad';
run;
*Create a new domain variable by applying the REORDER format;
data a;
set a;
Education2=put(Education, $reorder.);
run;
*Use the new domain variable in PROC SURVEYMEANS, and all of the domain quantile results are now correct;
title "Placing the empty domain last fixes the domain quantile results";
proc surveymeans data=a nobs mean median;
var y;
domain Education2;
run;
title;
Type: | Problem Note |
Priority: | high |
Topic: | Analytics ==> Survey Sampling and Analysis SAS Reference ==> Procedures ==> SURVEYMEANS |
Date Modified: | 2017-03-22 10:23:45 |
Date Created: | 2017-03-13 14:57:30 |